﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MagicBox
{
    public class MainViewModel : ViewModelBase
    {
        private string filePathFrom;
        private string filePathTo;

        public string FilePathFrom
        {
            get { return filePathFrom; }
            set
            {
                filePathFrom = value;
                NotifyPropertyChanged(() => FilePathFrom);
            }
        }

        public string FilePathTo
        {
            get { return filePathTo; }
            set
            {
                filePathTo = value;
                NotifyPropertyChanged(() => FilePathTo);
            }
        }

        public void SelectFile(bool isSourceFile)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            if((bool)openFileDialog.ShowDialog())
            {
                if(isSourceFile)
                    FilePathFrom = openFileDialog.FileName;
                else
                    FilePathTo = openFileDialog.FileName;
            }
        }

        public void ConvertToBase64()
        {
            Base64Encoder.FromBytesToText(filePathFrom, filePathTo);
        }

        public void ConvertToBinary()
        {
            Base64Encoder.FromTextToBytes(filePathFrom, filePathTo);
        }
    }
}
